﻿<UserControl x:Class="CapstoneProjectAEReader.GUIs.LibraryGUI.BookInformation"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <UserControl.Resources>
        <Style x:Key="rightTextBlockStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0"/>
        </Style>
        <Style x:Key="leftLabelStyle" TargetType="{x:Type Label}">
            <Setter Property="Width" Value="100"/>
            <Setter Property="Foreground" Value="Green"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0"/>
        </Style>
        <Style x:Key="EditableLabelStyle" TargetType="{x:Type Label}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Grid>
                            <TextBox Name="textBox"
                             Grid.ZIndex="1"
                             Padding="1,3,0,0"
                             Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type Label}}, Path=Content, UpdateSourceTrigger=PropertyChanged}"
                             HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                             Opacity="0"/>
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="textBox" Property="Opacity" Value="1"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid Width="600" Height="400">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <GroupBox x:Name="gbEbookDetail" Height="auto" HorizontalAlignment="Stretch" 
                  VerticalAlignment="Stretch" Margin="6,6,6,4" Grid.Row="0" Grid.ColumnSpan="2">
            <Grid Margin="6">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.6*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Border BorderThickness="2" Grid.Column="0" Margin="4">
                    <Border.BorderBrush>
                        <SolidColorBrush Color="LightGray" Opacity="70"/>
                    </Border.BorderBrush>
                    <Image x:Name="imgCover" Source="Image/NoBookCover.png" HorizontalAlignment="Left" Stretch="Fill" VerticalAlignment="Top" />
                </Border>

                <DockPanel Margin="20,4,4,4" Grid.Column="1">
                    <DockPanel.Resources>
                        <Style BasedOn="{StaticResource rightTextBlockStyle}" TargetType="{x:Type TextBlock}" />
                    </DockPanel.Resources>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbEbookTitle" Style="{StaticResource leftLabelStyle}"/>
                        <TextBlock x:Name="txtEbookTitle"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbAuthor" Style="{StaticResource leftLabelStyle}"/>
                        <TextBlock x:Name="txtAuthor"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbType" Style="{StaticResource leftLabelStyle}"/>
                        <TextBlock x:Name="lbTypeDt"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbImportDate" Style="{StaticResource leftLabelStyle}"/>
                        <Label x:Name="lbImportDateDt" Style="{StaticResource EditableLabelStyle}"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbImportPublisher" Style="{StaticResource leftLabelStyle}"/>
                        <Label x:Name="txtPublisher" Style="{StaticResource EditableLabelStyle}"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbGroup" Style="{StaticResource leftLabelStyle}"/>
                        <Button x:Name="btAddGroup" Background="Transparent" BorderThickness="0" Margin="2" 
                                DockPanel.Dock="Right" Click="HandleBtAddGroup" >
                            <Image Source="Image/ChoseGroup.png" Height="24" Width="24"/>
                        </Button>
                        <TextBlock x:Name="lbGroupDt"/>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbRating" Style="{StaticResource leftLabelStyle}"/>
                        <Image x:Name="imgRating" Height="24" Margin="1,1,1,1" HorizontalAlignment="Center" 
                               MouseMove="selectStarRating" MouseDown="choseStarRating" MouseLeave="checkStarRating" />
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Border BorderThickness="0.5" Margin="2,4,2,4">
                            <Border.BorderBrush>
                                <LinearGradientBrush>
                                    <GradientStop Color="#FFB0D9FF" Offset="0.1"/>
                                    <GradientStop Color="#FF51ABFF" Offset="0.3"/>
                                    <GradientStop Color="#FFB0D9FF" Offset="0.5"/>
                                    <GradientStop Color="#FF51ABFF" Offset="0.7"/>
                                    <GradientStop Color="#FFB0D9FF" Offset="0.9"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                        </Border>
                    </DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Label x:Name="lbDescription" Style="{StaticResource leftLabelStyle}"/>
                        <RichTextBox x:Name="txtDescription" VerticalScrollBarVisibility="Visible" 
                                     AcceptsReturn="True" AcceptsTab="True" Margin="4"/>
                    </DockPanel>
                </DockPanel>
            </Grid>
        </GroupBox>
        
        <Button x:Name="btBrowser" Background="Transparent" BorderThickness="0" Margin="8,4,4,4"
                Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Click="HandleBtBrowser" >
            <Grid>
                <Image Source="Image/Button.png" Height="24"/>
                <Label x:Name="lbBrowser" HorizontalAlignment="Center"/>
            </Grid>
        </Button>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="4" Grid.Column="1" Grid.Row="1">
            <Button x:Name="btSave" Background="Transparent" BorderThickness="0" Margin="4" Click="HandleBtSave" HorizontalAlignment="Left">
                <Grid>
                    <Image Source="Image/Button.png" Height="24"/>
                    <Label x:Name="lbSave" HorizontalAlignment="Center"/>
                </Grid>
            </Button>
            <Button x:Name="btCancel" Background="Transparent" BorderThickness="0" Margin="4" Command="ApplicationCommands.Close">
                <Grid>
                    <Image Source="Image/Button.png" Height="24"/>
                    <Label x:Name="lbCancel" HorizontalAlignment="Center"/>
                </Grid>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
